import request from '@/utils/request'

// 获取商品分类列表 (分页)
export function getCategoryList(params) {
  return request({
    url: '/goodCategory/list',
    method: 'GET',
    params
  })
}

// 获取所有分类 (不分页，用于下拉选择等)
export function getAllCategories() {
  return request({
    url: '/goodCategory/listAll',
    method: 'GET'
  })
}

// 根据ID获取分类详情
export function getCategoryById(id) {
  return request({
    url: `/goodCategory/${id}`,
    method: 'GET'
  })
}

// 新增分类
export function addCategory(data) {
  return request({
    url: '/goodCategory',
    method: 'POST',
    data
  })
}

// 更新分类
export function updateCategory(data) {
  return request({
    url: '/goodCategory',
    method: 'PUT',
    data
  })
}

// 删除分类
export function deleteCategory(id) {
  return request({
    url: `/goodCategory/${id}`,
    method: 'DELETE'
  })
}

// 更新分类状态
export function updateCategoryStatus(id, status) {
  return request({
    url: `/goodCategory/${id}/status`,
    method: 'PUT',
    params: { status }
  })
}
